<html lang="en" charset="utf-8">
<head>
	<meta charset="UTF-8">
	<title>个人认证</title>
	<link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/gerenxinxi_scss.css">
	<link rel="stylesheet" href="<?php echo IMG_PATH ?>bdkd/css/reset.css">
	<script src="<?php echo IMG_PATH ?>bdkd/js/flexible.js"></script>
	<script src="http://g.tbcdn.cn/mtb/lib-flexible/0.3.4/??flexible_css.js,flexible.js"></script>
	<script src="<?php echo IMG_PATH ?>bdkd/js/jquery-1.11.1.min.js"></script>
	<style>
		#imghead{
			margin-top: 0 !important;
		}
		#imghead1{
			margin-top: 0 !important;
		}
        input{
            background: #fff !important;
            border:none;
            outline:none;
        }
	</style>
</head>
<body>
	<div class="container">
		<div class="waikuang">
			<div class="touxiang">
                <img src="<?php echo $data->path;?>" />
			</div>
			<li>
				<div class="xm">
					<img src="<?php echo IMG_PATH ?>bdkd/img/ren.png" alt="">
					<span class="xingmin-ipt" id="bug">姓名 : <input id="name" style="background:#fff;" type="text" value="<?php

                        if(!empty($data->name)){
                            echo $data->name;
                        }
                        ?>
                        "
                        <?php
                        if(!empty($data->state) && $data->state==1){

                            ?>
                            readonly="readonly"
                            <?php
                        }
                        ?>
                 ></span>
				</div>
<!--				<p class="xiugai1">修改</p>-->
			</li>
			<li>
				<div class="xm-one">
					<img src="<?php echo IMG_PATH ?>bdkd/img/trell@2x.png" alt="">
                    <span class="iphone-a">电话 : <input id="phone" type="text" placeholder="请输入您的电话号码" value="<?php
                        if(!empty($data->phone)){
                            echo $data->phone;
                        }
                        ?>"

                        ></span>
                    <p class="xiugai1" style="float:right;">修改</p>
				</div>
			</li>
			<li>
				<div class="xm">
					<img src="<?php echo IMG_PATH ?>bdkd/img/身份证@2x.png" alt="">
					<span class="sfz-ipt" id="bug">身份证 : <input id="idCard" style="background:#fff;" placeholder="请输入您的身份证号码" type="text" value="<?php
                        if(!empty($data->idcard)){
                                echo $data->idcard;
                            }
                            ?>"
                            <?php
                            if(!empty($data->state) && $data->state==1){

                                ?>
                                readonly="readonly"
                                <?php
                            }
                            ?>
                  ></span>
				</div>
<!--        <p class="tianxie1">填写</p>-->
			</li>
			<li>
				<div class="xm" onclick="user();">

					<img src="<?php echo IMG_PATH ?>bdkd/img/adress@2x.png" alt=""/>
                    <span>我的地址 : <input type="text"  placeholder="请输入您的地址信息" value="<?php
                        if(isset($area->addres) && !empty($area->addres)){
                            echo $area->addres;
                        }

                        ?>
                    "></span>
					<img src="<?php echo IMG_PATH ?>bdkd/img/fanhui@2x.png" height="30" width="16" alt="">
				</div>
			</li>
			<div class="xzsf">
				<p>选择身份</p>
			</div>
			<!-- <div class="shenfen">
				<span><img src="gerenxinxi_img/组-2@2x.png" height="26" width="26" alt="">学生</span>
				<span><img src="gerenxinxi_img/组-2@2x.png" height="26" width="26" alt="">社会人</span>
			</div> -->
			<div class="shenfen">
                <span><input class="dxk1" type="radio" name="sex2" value="1"
                        <?php
                        var_dump($data->identity);
                        if(!empty($data->identity) && $data->identity==1){
                            echo 111;
                            ?>
                             checked="checked"
                            <?php
                        }
                        ?>

                    >学生</span>
                <span><input class="dxk2" type="radio" name="sex2" value="2"
                        <?php
                        if(!empty($data->identity) && $data->identity==2){
                            echo 222;
                            ?>
                            checked="checked"
                            <?php
                        }
                        ?>
                    >社会人</span>

			</div>
			<div class="shangchuan">
				<div class="zheng">
					<div id="preview">
			            <img id="imghead" border="0"
                             <?php
                            // var_dump($img);
                             if(!empty($data->state) && $data->state==1){
                                 ?>
                             src="<?php echo $img['idcard_oss1']?>"
                                 <?php
                             }else{
                                 ?>
                             src="<?php echo IMG_PATH ?>bdkd/img/照片-拷贝-2@2x.png" onclick="$('#previewImg').click();
                                 <?php
                             }
                             ?>
                             ">
			         </div>         
			        <input type="file" onchange="previewImage(this)" style="display: none;" id="previewImg">
			        <!-- <input  type="file" id="file"> -->
			        <p>身份证正面照</p>
				</div>
				<div class="fan">
					<div id="preview1">
			            <img id="imghead1" border="0"
                             <?php
                             if(!empty($data->state) && $data->state==1){
                                 ?>
                                 src="<?php echo  $img['idcard_oss2'];?>"
                                 <?php
                             }else{
                                 ?>
                                 src="<?php echo IMG_PATH ?>bdkd/img/照片-拷贝-2@2x.png" onclick="$('#previewImg1').click();
                                <?php
                             }
                             ?>


                             ">
			         </div>         
			        <input type="file" onchange="previewImage1(this)" style="display: none;" id="previewImg1">
			        <p>身份证正面照</p>
				</div>
				<span>*快递实行实名制，建议上传照片</span>
			</div>
			<div class="birth">
				<p><img src="<?php echo IMG_PATH ?>bdkd/img/dangao@2x.png" alt=""><span>我的生日</span><span>( 有礼物哦 )</span></p>
				<div class="data">
					<div class="nyr">
                        <?php
                        if(!empty($data->birthday) && !empty($data->state) && $data->state==1){
                            echo $data->birthday;
                        }else{
                            ?>
                            <input id="year" type="text" value="">
                            <span>年</span>
                            <input id="month" type="text" value="" >
                            <span>月</span>
                            <input id="day" type="text" value="">
                            <span>日</span>
                            <?php
                        }
                        ?>

					</div>
					<span><input type="radio" name="sex3" value="3">农历</span>
				</div>
			</div>
			<a style="text-decoration:none;"><div class="btn box"
                                                  <?php
                                                  //var_dump($data->state);//这个是 0
                                                  if($data->state!="1"){
                                                      ?>
                                                      onclick="upuser()"
                                                      <?php
                                                  }else{
                                                      ?>
                                                      onclick="isrz()"
                                                      <?php
                                                  }
                                                  ?>

                                                  >认证</div></a>
		</div>
	</div>
    <input class="pic1_data" type="hidden" value="">
    <input type="hidden" class="pic2_data" value="">
<!--	<script src="--><?php //echo IMG_PATH ?><!--bdkd/js/gerenxinxi.js"></script>-->
	<script>
        function isrz() {
            alert("您已认证,请勿重复认证!");
        }

        $(function () {
            $("input").focus(function(){
                $("input").css("background-color","#FFFFCC");
            });
        });


        function user() {
            window.location.href = '<?php echo SITE_PATH ?>work/buser/uaddres';
        }
        function upuser() {

            var name=$("#name").val();

            var idCard=$("#idCard").val();
            var identity=$("input[type='radio']:checked").val();

            var year=$("#year").val();
            var month=$("#month").val();
            var day=$("#day").val();
            var h = $('.pic1_data').val();
            var h1 = $('.pic2_data').val();
            if(year==0 || month==0 || day==0){
                alert("请填写生日!");
            }else {
                var birthday=year+'年'+month+'月'+day+'日';
            }

            console.log(year);

            console.log(idCard);

            console.log(identity);
            console.log(birthday);


            $.ajax({
                // 请求发送方式
                type: 'post',
                // 验证文件
                url: '<?php echo SITE_PATH ?>work/buser/upUser',
                dataType:'json',
                // 用户输入的帐号验证码
                data: {
                    'name':name,
                    'idcard':idCard,
                    'identity':identity,
                    'birthday':birthday,
                    'path1':h,
                    'path2':h1
                },
                success: function(data){
                    console.log(data);
                    if(data.result==1){
                        alert("修改成功!");

                    }else{
                        alert(data.msg);
                    }
                },
                error: function(){
                    alert('提交失败!!');
                }

            })
        }




        function previewImage(file)
        {
            var MAXWIDTH  = 90;
            var MAXHEIGHT = 90;
            var div = document.getElementById('preview');
            if (file.files && file.files[0])
            {
                div.innerHTML ='<img id=imghead onclick=$("#previewImg").click()>';
                var img = document.getElementById('imghead');
                img.onload = function(){
                    var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                    img.width  =  rect.width;
                    img.height =  rect.height;
//                 img.style.marginLeft = rect.left+'px';
                    img.style.marginTop = rect.top+'px';
                    var h = $('#imghead').attr('src');
//                    console.log(h);
                    $('.pic1_data').val(h);
//                    console.log($('.pic1_data').val());
                }
                var reader = new FileReader();
                reader.onload = function(evt){img.src = evt.target.result;}
                reader.readAsDataURL(file.files[0]);

            }
            else //兼容IE
            {
                var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
                file.select();
                var src = document.selection.createRange().text;
                div.innerHTML = '<img id=imghead>';
                var img = document.getElementById('imghead');
                img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
                div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
            }

        }
        function clacImgZoomParam( maxWidth, maxHeight, width, height ){
            var param = {top:-20, left:0, width:width, height:height};
            if( width>maxWidth || height>maxHeight ){
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;

                if( rateWidth > rateHeight ){
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else{
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;

        }








        function previewImage1(file)
        {
            var MAXWIDTH  = 90;
            var MAXHEIGHT = 90;
            var div = document.getElementById('preview1');
            if (file.files && file.files[0])
            {
                div.innerHTML ='<img id=imghead1 onclick=$("#previewImg1").click()>';
                var img = document.getElementById('imghead1');
                img.onload = function(){
                    var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                    img.width  =  rect.width;
                    img.height =  rect.height;
//                 img.style.marginLeft = rect.left+'px';
                    img.style.marginTop = rect.top+'px';
                    var h1 = $('#imghead1').attr('src');
                    $('.pic2_data').val(h1);
//                    console.log(h1);
                }
                var reader = new FileReader();
                reader.onload = function(evt){img.src = evt.target.result;}
                reader.readAsDataURL(file.files[0]);
            }
            else //兼容IE
            {
                var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
                file.select();
                var src = document.selection.createRange().text;
                div.innerHTML = '<img id=imghead1>';
                var img = document.getElementById('imghead1');
                img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
                div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
            }
        }
        function clacImgZoomParam( maxWidth, maxHeight, width, height ){
            var param = {top:-20, left:0, width:width, height:height};
            if( width>maxWidth || height>maxHeight ){
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;

                if( rateWidth > rateHeight ){
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else{
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;
        }



        var custom_num=0;
        function custom_huantu(ele){
            var tupian1 = $(ele).attr("src");
            var newSrc = tupian1 === './gerenxinxi_img/组-@2x.png'?'./gerenxinxi_img/组-1@2x.png':'./gerenxinxi_img/组-@2x.png';
            $(ele).attr("src",newSrc);
        }
        $('.dxk1').click(function(){
            console.log($('.dxk1').val());
        })
        $('.dxk2').click(function(){
            console.log($('.dxk2').val());
        })
        $('.data span img').click(function(){
            custom_huantu(this);
            custom_num=custom_num===0?1:0;
        })


        $('.xiugai1').click(function(){

            $('.iphone-a input').val('');
            $('.iphone-a input').removeAttr('disabled');

            $('.iphone-a input').blur(function(){
                $('.iphone-a input').attr('disabled','true');
                var phone=$("#phone").val();
                //console.log(phone);return false;
                $.ajax({
                    // 请求发送方式
                    type: 'post',
                    // 验证文件
                    url: '<?php echo SITE_PATH ?>work/buser/upphone',
                    dataType:'json',
                    // 用户输入的帐号验证码
                    data: {
                        'phone':phone
                    },
                    success: function(data){
                        console.log(data);
                        if(data.result==1){
                            alert('手机号修改成功!');
                        }else {
                            alert(data.msg);
                        }
                    },
                    error: function(){
                        alert('手机号修改失败!');
                    }

                })

            })
        })
        $('.tianxie1').click(function(){
            $('.sfz-ipt input').val('');
            $('.sfz-ipt input').removeAttr('disabled');
            $('.sfz-ipt input').blur(function(){
                if($('.sfz-ipt input').val().length>=18){
                    var sfzh = $('.sfz-ipt input').val().substring(0,6);
                    var sfzh1 = $('.sfz-ipt input').val().substring(14,18);
                    console.log(sfzh1);
                    console.log(sfzh);
                    var sfzh2 = sfzh+'********'+sfzh1;
                    $('.sfz-ipt input').val(sfzh2);
                    $('.sfz-ipt input').attr('disabled','true');
                }

            })
        })
        var dizhi = $('.xm span input').html();
        if(dizhi.length>=9){
            var dizhi1 = $('.xm span input').html().substring(0,9);
            var dizhi2 = dizhi1+'…';
            $('.xm span input').html(dizhi2);

        }

    </script>
		

</body>
</html>